<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>练习3</title>
		<script type="text/javascript">
			
			/*
				5个人相约100米赛跑，创建5个对象，包含姓名：name，性别：sex，年龄：age，速度：speed，
				注意：速度是一个5-10之间的随机整数.：比赛结束后：输出第一名的人的姓名和所花时间
			
			*/
			//定义一个构造函数
			function Persion(name,sex,age,speed) {
				this.name = name;
				this.sex = sex;
				this.age = age;
				this.speed = speed;
			}
			
			//创建5个对象
			let per1 = new Persion("张三","男",20,(Math.floor(Math.random() * 6) + 5));
			let per2 = new Persion("李四","女",22,(Math.floor(Math.random() * 6) + 5));
			let per3 = new Persion("王五","男",20,(Math.floor(Math.random() * 6) + 5));
			let per4 = new Persion("赵六","女",23,(Math.floor(Math.random() * 6) + 5));
			let per5 = new Persion("林七","男",19,(Math.floor(Math.random() * 6) + 5));
			
			let arr = [per1,per2,per3,per4,per5];
			let firstSpeed = 0;
			for (var i = 0; i < arr.length; i++) {
				console.log(arr[i].name + " " + [i].speed);
				if(arr[i].speed > firstSpeed) {
					firstSpeed = arr[i].speed;
				}
			}
			console.log("firstSpeed:" + firstSpeed);
		</script>
	</head>
	<body>
	</body>
</html>
